<?php echo $this->element('estilos/tablas'); ?>
<?php $idUsuario = $usuarios['User']['id'] ?>
<div class="col-lg-12">
    <section class="panel">
        <header class="panel-heading">
            <h4>
                <?php echo $usuarios['User']['nombre']; ?>
            </h4>
            <span class="tools pull-right">
                <a href="javascript:;" class="fa fa-chevron-down"></a>
                <a href="javasrcipt:;" class="fa fa-cog"></a>
                <a href="javascript:;" class="fa fa-times"></a>
            </span>
        </header>
        <div class="panel-body">
            <div class="row">
                <div class="col-sm-8">
                    <section class="panel">
                        <header class="panel-heading no-border">
                            Lista de asignaciones
                            <span class="tools pull-right">
                                <a href="javascript:;" class="fa fa-chevron-down"></a>
                                <a href="javascript:;" class="fa fa-cog"></a>
                                <a href="javascript:;" class="fa fa-times"></a>
                            </span>
                        </header>
                        <div class="panel-body">
                          <div class="adv-table">  
                            <table  class="display table table-bordered table-striped" id="dynamic-table">
                                <thead>
                                    <tr>
                                        <th>Nro.</th>
                                        <th>Destino</th>
                                        <th>Acciones</th>
                                    </tr>
                                </thead>
                                <tbody>  
                                    <?php $i = 1; ?>
                                    <?php //debug ($permitidos);?>
                                    <?php foreach ($permitidos as $permit): ?>
                                         <tr class="gradeC">
                                            <td><?php echo $i;$i++; ?></td>
                                            <td><?php echo $permit['Destino']['nombre'] ?></td>
                                            <td>
                                                <?php if ($permit['Permitido']['estado'] == 'Activo'):
                                                            echo $this->Html->image("iconos/desabilitar.png", array("title" => "Habilitar",
                                                                            'url' => array('controller'=>'Permitidos','action' => 'baja', $permit['Permitido']['id'],$idUser)));
                                                            else: 
                                                            echo $this->Html->image("iconos/habilitar.png", array("title" => "Deshabilitar",
                                                                            'url' => array('controller'=>'Permitidos','action' => 'alta', $permit['Permitido']['id'],$idUser)));
                                                    endif; ?>
                                                <?php echo $this->Html->link($this->Html->image('iconos/del.png'), array('controller'=>'Permitidos','action'=>'eliminar', $permit['Permitido']['id'],$idUser), array('escape'=>false, 'confirm'=>'Esta seguro de Eliminar')); ?>
                                            </td>
                                        </tr>
                                        <?php $i++; ?> 
                                    <?php endforeach; ?> 
                                </tbody>
                            </table>
                          </div>
                        </div>
                    </section>
                </div>
                <div class="col-sm-4" id="nuevaAsignacion">
                    <section class="panel">
                        <header class="panel-heading">
                            Nueva asignacion
                            <span class="tools pull-right">
                                <a href="javascript:;" class="fa fa-chevron-down"></a>
                                <a href="javascript:;" class="fa fa-cog"></a>
                                <a href="javascript:;" class="fa fa-times"></a>
                            </span>

                        </header>
                        <div class="panel-body">
                            <?php echo $this->Form->create('Permitido', array('class' => 'form-horizontal')); ?>
                            <?php echo $this->Form->hidden('user_id', array('value' => $idUser)) ?>
                            <div class="form-group has-success">
                                <lavel class="col-lg-2 control-label" for="data[Permitido][user_id]">Nombre</lavel>
                                <div class="col-lg-8">
                                    <?php echo $this->Form->select('destino_id', $destino, array('class' => "form-control", 'required')) ?>
                                    <p class="help-block">Seleccione algun destinatario.</p>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-lg-offset-3 col-lg-3">
                                    <button class="btn btn-primary" type="submit">Guardar</button>  
                                </div>
                            </div>
                        </div>
                    </section>
                </div>
            </div>

        </div>
    </section>
</div>
<?php echo $this->element('scripts/tablas'); ?>